﻿@model WebUI.Models.CoEditProfileViewModel
@{
    ViewBag.Title = "Edit Company Profile - JuicyBasket";
    Layout = "~/Views/Shared/_Layout.cshtml";
}

@section NotificationContent
{
    @if (!Model.Login.EmailConfirmed)
    {
        <div class="at-notification">
            An email has been sent to your email address (@Model.Login.Email). Please check your email inbox and confirm your email address. Don't receive it? 
            <a href="@Url.Action("SendEmailConfirmation")">Resend confirmation email</a>
        </div>
    }
}

<h1><a href="@Url.Action("EditProfile")">Account</a> / Profile</h1>
<div class="editdes">Edit your account information, company profile, and profile picture</div>
<div class="spacer"></div>

<ul class="tabs">
    <li class="active">
        <a href="@Url.Action("EditProfile")">Profile</a>
    </li>
    <li>
        <a href="@Url.Action("EditPassword")">Password</a>
    </li>
</ul>
<div class="tabsbottom"></div>


<div class="mainSection atl">
    <div class="clear"></div>
    @using (Html.BeginForm("EditAvatar", "Co", FormMethod.Post, new { ID = "EditAvatarForm" }))
    { 
        <div class="fl left">Profile Picture</div>
        <div class="fl right">
            <div class="avatar80 fl">
                <img id="avatar-url" class="avatar80" src="@Url.StaticFile(Model.AvatarUrl)" alt="Avatar" width="80" height="80"/>
            </div>
            <div class="vspacer"></div>
            <div class="fl">
                <div><input type="file" name="avatar" class="file-input"/></div>
                <div class="smallspacer"></div>
                <div>Maximum size of 700k. JPG, GIF, PNG.</div>
            </div>
            <div class="fl client-validation-error" id="avatar-error"></div>
            <div class="clear"></div>
        </div>
        <div class="spacer"></div>
        <div class="clear"></div>
        
        <div class="fl left">&nbsp;</div>
        <div class="fl right">
            <input class="blue-submit" type="submit" name="submitAvatar" value="Update now" />
        </div>
    }

    <div class="clear"></div>
    @using (Html.BeginForm())
    {
        <div class="clear"></div>
        <div class="tabsbottom"></div>
        <div class="fl"><strong style="font-size:14px;">Account Information</strong></div>
        <div class="spacer"></div>
        
        <div class="fl left">Email Address<span>&nbsp;*</span></div>
        <div class="fl right right-text">@Html.DisplayTextFor(m => m.Login.Email)
        </div>
        <div class="clear"></div>
        <div class="fl left">User Name<span>&nbsp;*</span></div>
        <div class="fl right">
            @Html.TextBoxFor(m => m.Login.UserName)
            @Html.ValidationMessageFor(m => m.Login.UserName)
        </div>

        <div class="clear"></div>
        <div class="spacer"></div>
        <div class="tabsbottom"></div>
        <div class="fl"><strong style="font-size:14px;">Company Information</strong></div>
        <div class="spacer"></div>
            
        <div class="clear"></div>
        <div class="fl left">Company Name<span>&nbsp;*</span></div>
        <div class="fl right">
            @Html.TextBoxFor(m => m.Co.Name)
            @Html.ValidationMessageFor(m => m.Co.Name)
        </div>
        <div class="minispacer"></div>
            
        <div class="clear"></div>
        <div class="fl left">Company Type<span>&nbsp;*</span></div>
        <div class="fl right">
            @Html.DropDownListFor(m => m.Co.CoTypeID, Model.CoTypeList)
        </div>
        <div class="minispacer"></div>
            
        <div class="clear"></div>
        <div class="fl left">Company URL<span>&nbsp;*</span></div>
        <div class="fl right">
            @Html.TextBoxFor(m => m.Co.CoUrl)
            @Html.ValidationMessageFor(m => m.Co.CoUrl)
        </div>
        <div class="clear"></div>
        <div class="fl left left-tip">&nbsp;</div>
        <div class="fl right right-tip">http or https required</div>
        <div class="spacer"></div>
            
        <div class="clear"></div>
        <div class="fl left">Company Location</div>
        <div class="fl right">
            @Html.TextBoxFor(m => m.Co.Location)
            @Html.ValidationMessageFor(m => m.Co.Location)
        </div>
        <div class="smallspacer"></div>
            
        <div class="clear"></div>
        <div class="fl left">Company Description</div>
        <div class="fl right">
            @Html.TextAreaFor(m => m.Co.Description, new { ID = "coDesTextArea" })
            @Html.ValidationMessageFor(m => m.Co.Description)
        </div>

        
        
        <div class="clear"></div>
        <div class="spacer"></div>
        <div class="fl left">&nbsp;</div>
        <div class="fl right">
            <input class="blue-submit" type="submit" name="submitProfile" value="Save changes" />
        </div>
        <div class="clear"></div>
    }
    
    <div class="clear"></div>

</div>

@section FooterContent
{
    <script type="text/javascript" src="@Url.StaticFile("~/content/tinyMCE/tiny_mce.js", true)"></script>
    <script type="text/javascript" src="@Url.StaticFile("~/content/jquery.form.js")"></script>
    <script type="text/javascript">

        $(function () {
            initTinyMCE("coDesTextArea", 416, 400);

            textAreaCharsRemaining("Ind_Bio", "bio_totalchars", 200);

            //avatar form
            $("#EditAvatarForm").ajaxForm({
                beforeSubmit: function (a, f, o) {
                },
                dataType: 'json',
                success: ProcessAvatar,
                error: function (request, status, errorThrown) {     // error during save, display error
                    //alert(request.responseText);
                    return false;
                }
            });
            
        })

        function ProcessAvatar(data) {
            JsonResultUploadFileHandler.Success(data);
            if (data.Success == 1) {
                $("#avatar-url").attr("src", data.FilePath);
            }
        }
    </script>
}


